import requests



class ad:
    def __init__(self):
        self.seeeion = requests.session()
        self.seeeion.get(url="http://192.168.4.80/TinyShop_v1.7/index.php?con=simple&act=captcha&h=40&w=120&bc=3f4657&c=ffffff")
        url = "http://192.168.4.80/TinyShop_v1.7/index.php?con=admin&act=check"
        data = {"name":"admin","password":"123456","verifyCode":"aaaa"}
        re = self.seeeion.post(url=url,data=data)
        # print(re.text)

    def add(self,id,typeid,brandid,name,shichangjia,yujingxian,lingshoujia,chengben):
        add_url = "http://192.168.4.80/TinyShop_v1.7/index.php?con=goods&act=goods_edit"
        data1 = {"category_id":id, "type_id":typeid,"brand_id":brandid,"name":name,"tag_id":"hehe","goods_no":12121,"point":0,"sort":1,"unit":"%E4%BB%B6&imgs%5B%5D=data%2Fuploads%2F2014%2F05%2F04%2Ff81d28ad7c32504c0af3a8c44eec681e.jpg","img":"data%2Fuploads%2F2014%2F05%2F04%2Ff81d28ad7c32504c0af3a8c44eec681e.jpg","spec_items":6,"pro_no%5B%5D":"12121_1 &spec_item%5B%5D=45%3AL%3AL%3A","store_nums%5B%5D":100, "warning_line%5B%5D":yujingxian,"sell_price%5B%5D":lingshoujia, "market_price%5B%5D":shichangjia,"cost_price%5B%5D":chengben,"weight%5B%5D":1000,"content":"", "seo_title":"","seo_keywords":"","seo_description":"", "sale_protection":""}
        r = self.seeeion.post(url=add_url,data=data1)
        print(r.text)
        return r
if __name__ == "__main__":
    l = ad()
    l.add("5","0","0","shabi","1","1","1","1")
